window.onload = function () {
    var username = document.querySelector('#username')
    var password = document.querySelector('#password')
    var login = document.querySelector('#login')



    login.addEventListener('click', () => {
        // if (username.value == uname && password.value == upw) {
        $.ajax({
            type: 'post',				// 请求方式
            url: 'http://127.0.0.1:3007/api/login',		// 路径
            // contentType: "application/json",
            dataType: 'json',		// 这里是指定了参数的类型
            data: {
                'username': username.value,
                'password': password.value
            }
            ,
            success: function (res) {
                console.log(res);
                // var yanzheng = { status: 0, message: '登录成功！' }
                if (res.status == 0) {
                    alert('登录成功');
                    self.location.href = "index.html?id=" + res.id;
                }
                else {
                    alert('请输入正确的用户名或密码')
                }

            }

        })



    })
}